//
//  HLPlayControlView.m
//  HLMusicBox
//
//  Created by hulinhu on 2017/12/27.
//  Copyright © 2017年 hulinhu. All rights reserved.
//

#import "HLPlayControlView.h"

@implementation HLPlayControlView

- (instancetype)initWithFrame:(CGRect)frame
             playViewBtnClick:(btnClick)btnClick {
    self =  [super initWithFrame:frame];
    if (self) {
        float height = self.height;
        float width = self.width;
        
        //  转动唱片
        self.playSongImage = [[HLImageView alloc] initWithFrame:CGRectMake(height*0.1, -height*0.2, height*1.1, height*1.1)];
        self.playSongImage.image = [UIImage imageNamed:@"cm2_simple_defaut_album_image"];
        self.playSongImage.clipsToBounds = YES;
        self.playSongImage.layer.cornerRadius = height*1.1*0.5;
        self.playSongImage.layer.masksToBounds = YES;
        self.playSongImage.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id gestureRecognizer) {
            !btnClick?:btnClick(MUSIC_DETAIL);
        }];
        tap.numberOfTapsRequired = 1;
        [self.playSongImage addGestureRecognizer:tap];
        [self addSubview:self.playSongImage];
    
        // 进度条
        self.songSlider = [[UISlider alloc] initWithFrame:CGRectMake(height*1.3, 0, width-height*1.3, height*0.3)];
        [self.songSlider setThumbImage:[UIImage imageNamed:@"cm2_simple_knob_nomal"] forState:UIControlStateNormal];
        [self.songSlider setThumbImage:[UIImage imageNamed:@"cm2_simple_knob_prs"] forState:UIControlStateHighlighted];
        self.songSlider.tintColor  = UIColorHex(FFFFFF);
        [self addSubview:self.songSlider];
        
        // 播放暂停
        self.playAndPauseBtn = [GFControl createImageViewWithFrame:CGRectMake(width*0.75, height*0.25, height*0.65, height*0.65) imageName:@"cm2_fm_btn_pause" roundCorner:NO tapAction:^{
            !btnClick?:btnClick(MUSIC_BEGPAUSE);
        }];
        [self addSubview:self.playAndPauseBtn];
        
        // 下一曲
        self.nextSongBtn = [GFControl createImageViewWithFrame:CGRectMake(width*0.88, height*0.25, height*0.65, height*0.65) imageName:@"cm2_fm_btn_next" roundCorner:NO tapAction:^{
            !btnClick?:btnClick(MUSIC_NEXTONE);
        }];
        [self addSubview:self.nextSongBtn];
        
        // 歌曲名
        self.songName = [GFControl createLabelWithFrame:CGRectMake(height*1.3, height*0.3, width*0.5, height*0.3) text:@"Unkown" textAlignment:NSTextAlignmentLeft fontSize:16];
        [self addSubview:self.songName];
        
        
        // 歌手
        self.singerName = [GFControl createLabelWithFrame:CGRectMake(height*1.3, height*0.7, width*0.5, height*0.2) text:@"Unkown" textAlignment:NSTextAlignmentLeft fontSize:13 textColor:UIColorHex(FAFAFA)];
        [self addSubview:self.singerName];

      
    }
    return self;
    
}

#pragma mark
#pragma mark - 数据绑定
-(void)setModel:(NSObject *)model {
    
    
    
}

@end
